Xbasic

a5w_SaveToWorkQueue Function

Syntax

L lResult = a5w_SaveToWorkQueue(P pValues ,P pResult )

Arguments

lResult

.t. or .f. depending on whether the command succeeded.

pValues

A dot variable that has in/out properties (explained below)

pResult

A dot variable that two properties, 'hasError' - .t./.f. and 'errorText' (if there is an error)

Description

Used in a Web application to save data to the Work Queue.

pValues is a dot variable. When you are inserting or updating a record, you must set these properties of pValues:

ID (Guid)
CreatedWhen (DateTime)
WorkType (C)
IsLocked (N)
SchedulatedStartTime (DateTime)
HandledBy (C)
IsCompleted (N)
CompletedDateTime (t)
Status (C)
WorkData (c)
ErrorMessage (c)
Message (c)

pValues.ID is the GUID primary key of the record. When you are inserting a new record, you can leave pValues.id blank, and a Guid will automatically be assigned to the new record. You can read pValues.id after the insert to see what value was assigned.

Used in a Web application to save data to the Work Queue. The Work Queue must already have been defined in the Web Project Properties, and the Work Queue database must be online. This function obtains the Work Queue connection string and field map from the Web Project Properties, then inserts the passed properties into the Work Queue database. The primary key of a work item is a GUID. if you don't pass in the GUID, it is automatically created and returned in pValues.id. The function will set pResult.errorText to an error message if the task insertion fails.

Example

dim pv as p
pv.WorkData = <<%txt%
'this is the definition of some work to do
%txt%
dim pr as p
flag =  a5w_SaveToWorkQueue(pv,pr)
'see what id was assigned, since none was set in advance
?pv.id
 = "{cb23f599-10a1-45bc-a491-3ca5450e7698}"

'Now read what was written
flag = a5w_ReadFormWorkQueue(pv,pr)
?pv
= CompletedDateTime = 
CreatedWhen = 06/23/2011 11:31:31 00 am
ErrorMessage = ""
HandledBy = ""
id = "{cb23f599-10a1-45bc-a491-3ca5450e7698}"
IsCompleted = 0
IsLocked = 0
Message = ""
SchedulatedStartTime = 06/23/2011 11:31:31 00 am
Status = ""
WorkData = ""
WorkType = ""

'Now update a value
pv.id = "{cb23f599-10a1-45bc-a491-3ca5450e7698}"
pv.isCompleted = 1
pv.completedDateTime = now()
flag = a5w_UpdateWorkQueue(pv,pr)

Limitations

Note that you must process the Work Queue elsewhere.

See Also